//
//  ContentView.swift
//  SwiftUIState
//
//  Created by 李煜 on 2024/7/31.
//

import SwiftUI

struct ContentView: View {
  @State private var counter = 1
  var body: some View {
    VStack {
      CounterButton(counter: $counter, color: .blue)
      CounterButton(counter: $counter, color: .green)
      CounterButton(counter: $counter, color: .red)
    }
  }
}
struct CounterButton: View {
  @Binding var counter: Int
  
  var color: Color
  
  var body: some View {
    Button {
      counter += 1
    } label: {
      Circle()
        .frame(width: 200, height: 200)
        .foregroundStyle(color)
        .overlay {
          Text("\(counter)")
            .font(.system(size: 100, weight: .bold, design: .rounded))
            .foregroundStyle(.white)
        }
    }
  }
}
#Preview {
  ContentView()
}
